package com.larry.rabbitmq.sisth;

import com.larry.rabbitmq.util.RabbitMQUtils;
import com.rabbitmq.client.BuiltinExchangeType;
import com.rabbitmq.client.Channel;

/**
 * @author larry
 * @Title: larry-rabbitmq
 * @Package com.larry.rabbitmq.sisth
 * @Description: 直接模式
 * @date 6/30/2110:32 AM
 */
public class ReceiveLogsDirect02 {
    public static final String EXCHANGE_NAME = "direct_logs";

    public static void main(String args[]) throws Exception{
        Channel channel = RabbitMQUtils.getChannel();

        //声明一个交换机
        channel.exchangeDeclare(EXCHANGE_NAME, BuiltinExchangeType.DIRECT);

        //声明一个队列
        channel.queueDeclare("disk",false,false,false,null);
        /**
         * 绑定交换机与队列
         */
        channel.queueBind("disk",EXCHANGE_NAME,"error");

        //接收消息
        channel.basicConsume("disk",true,(consumerTag, message) -> {
            System.out.println("02收到的消息.....: " + new String(message.getBody()));
        },consumerTag -> {});
    }
}
